package com.ihr360.expr;

import com.ihr360.expr.context.IEvaluationContext;
import com.ihr360.expr.core.Expr;
import com.ihr360.expr.core.ExprEvaluatable;
import com.ihr360.expr.core.ExprType;

public class ExprExpression extends ExprEvaluatable
{
    private Expr child;

    public ExprExpression(Expr child) {
        super(ExprType.Expression);
        this.child = child;
    }

    public Expr evaluate(IEvaluationContext context) throws ExprException {
        if (child instanceof ExprEvaluatable)
            return ((ExprEvaluatable) child).evaluate(context);
        else
            return child;
    }

    public Expr getChild() {
        return child;
    }

    public String toString() {
        return "(" + child + ")";
    }

    public void validate() throws ExprException {
        child.validate();
    }
}